
function Selection(targets,collisionType,base){
	if(!base){
		base = document.body.appendChild(document.createElement("div"));
		base.className="selection";
	}
	if(collisionType)this.collisionType=collisionType;
	
	base.unselectable="on";
	base.style.MozUserSelect="none";
	base.style.KhtmlUserSelect="none";
	
	this.base = base;
	this.targets = targets;
	this.hitTest = this.targets instanceof Array ? DnD.collision.manyTargets : DnD.collision.oneTarget;
	this.hitTest.type = DnD.collision.type[this.collisionType];
	this.start.selection = this;
	compono.Event.add("mousedown",this.start,document);
}

Selection.prototype={
	/**
	 * Tipo de colisao default
	 */
	collisionType:"edgeBox",
	
	start:function(e){
		var s = arguments.callee.selection;
		var o = arguments.callee.selection.base;
		s.move.selection = s;
		s.stop.selection = s;
		o.y = e.clientY;
		o.x = e.clientX;
		o.style.top = (o.y)+"px";
		o.style.left = (o.x)+"px";
		o.style.width = "0";
		o.style.height = "0";
		o.style.display = "block";
		compono.appendClassName("selection-active",o);
		document.addEventListener("mousemove",s.move,document);
		document.addEventListener("mouseup",s.stop,document);
	},
	
	move:function(e){
		var s = arguments.callee.selection;
		var o = arguments.callee.selection.base;
		o.style.width=(e.clientX-o.x)+"px";
		o.style.height=(e.clientY-o.y)+"px";
		s.hitTest(o);
	},
	
	stop:function(e){
		var s = arguments.callee.selection;
		var o = arguments.callee.selection.base;
		compono.removeClassName("selection-active",o);
		document.removeEventListener("mousemove",s.move,document);
		document.removeEventListener("mouseup",s.stop,document);
	},
	
	onSelectStart:false,
	onSelectMove:false,
	onSelectEnd:false,
	onCollide:false,
	onNotCollide:false,
	hitTest:function(){},
	toString:function(){return "Selection";}
}
